package com.loveyukari.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.loveyukari.Interceptor.IpInterceptor;
import com.loveyukari.Interceptor.LoginInterceptor;

/**
*
*yangshaohua
*2017年10月11日下午2:24:45
**/
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
	
	@Autowired
    IpInterceptor ipInterceptor;
    @Autowired
    LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(ipInterceptor).addPathPatterns("/**").excludePathPatterns("/admin/blackIp/**");
        registry.addInterceptor(loginInterceptor).addPathPatterns("/admin/**").excludePathPatterns("/admin/blackIp/**");
    }
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    	registry.addResourceHandler("/css/**").addResourceLocations("classpath:/css/");
    	registry.addResourceHandler("/font/**").addResourceLocations("classpath:/font/");
    	registry.addResourceHandler("/bootstrap/**").addResourceLocations("classpath:/bootstrap/");
    	registry.addResourceHandler("/images/**").addResourceLocations("classpath:/images/");
    	registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
    	registry.addResourceHandler("/file/**").addResourceLocations("classpath:/file/");
    }

}
